package com.elinshaw;

import org.apache.storm.Config;
import org.apache.storm.LocalCluster;
import org.apache.storm.generated.StormTopology;
import org.apache.storm.topology.TopologyBuilder;

/**
 * @author Administrator
 */
public class TopologyLocalRouter {

    public static void main(String[] args) {
        Config config = new Config();
        //用户绑定各组件间的上下游关系
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("number_spout", new NumberSpout());
        builder.setBolt("router_bolt", new RouterBolt()).shuffleGrouping("number_spout");
        builder.setBolt("more_than_bolt", new MoreThanBolt()).shuffleGrouping("router_bolt", "moreThan");
        builder.setBolt("less_than_bolt", new LessThanBolt()).shuffleGrouping("router_bolt", "lessThan");
        //生成一个Job任务
        StormTopology stormTopology = builder.createTopology();
        //本地模式提交-创建本地测试对象
        LocalCluster cluster = new LocalCluster();
        //提交拓扑运行
        cluster.submitTopology("DemoTopologyLocal", config, stormTopology);
    }


}
